package com.tecnap.app.database;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

/**
 * This class is used to mantain a connection between
 * Database and Application
 *
 */
public class DataSource {
	// Access to Database SQLite API
	protected DatabaseHelper database_helper;
	protected SQLiteDatabase database;
	
	/**
	 * @param context
	 */
	public DataSource( Context context ) {
		database_helper = new DatabaseHelper(context);
	}
	
	/**
	 * This method should be called in onStart() of each Activity
	 * @param context
	 * @throws SQLException
	 */
	public void open() throws SQLException {
		database = database_helper.getWritableDatabase();
	}

	/**
	 * This method should be called in onStop() of each Activity
	 * @param context
	 */
	public void close() {
		database.close();
	}
}
